<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet"
			href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
.ui-tabs .ui-tabs-panel {
	border-width: 0;
	padding: 0.4em 0.4em;
	background: 0;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class='full-center-content-scroll-noheader'>
			<div class="col-sm-12 col-lg-12">
				<h:form id="headForm">
					<p:remoteCommand name="rc" update="headForm:tabv" actionListener="#{lineSegmentLedgerController.execute}" />
					<p:growl id="msgs" showDetail="true" />
					<div class="box box-solid with-border">
						<div class="box-header">
							<p:outputLabel value="电压等级：" style="margin-right:5px;" />
							<h:selectOneMenu id="vol"
								value="#{lineSegmentLedgerController.selectdStandVolLevel}"
								style="width:100px;height:30px;margin-right:15px;">
								<f:selectItem itemLabel="全部" itemValue="" />
								<f:selectItems var="vol" value="#{ledgerQueryDataController.standVoltageLevels}"
									itemLabel="#{vol.label}" itemValue="#{vol.value}" />
							</h:selectOneMenu>
							<p:outputLabel value="线路名称：" style="margin-right:5px;" />
							<p:autoComplete id="lineSearch" dropdown="true"
								placeholder="线路首字母查询" scrollHeight="400" size="18"
								value="#{lineSegmentLedgerController.equipmentName}"
								style="margin-right:15px;"
								completeMethod="#{cimUtilController.completeLineSegment}">
							</p:autoComplete>
							<p:commandButton icon="ui-icon-search" value="查询" onclick="closeDivClick();"
								actionListener="#{lineSegmentLedgerController.query()}"
								update="headForm:tabv" style="margin-left:5px;" />
							<p:commandButton icon="ui-icon-refresh" value="重置" onclick="closeDivClick();"
								actionListener="#{lineSegmentLedgerController.resetQueryCondition}"
								update="headForm:tabv headForm:dispatchUnit_id headForm:maintenanceUnit_id headForm:assetOwner_id headForm:primary_id headForm:secondary_id headForm:lineSearch headForm:vol"
								style="margin-left:5px;" />
							<div class="box-tools pull-right">
								<button type="button" id="selectButton" title="高级查询"
									class="btn btn-default" onclick="onSelectDivClick();"
									style="margin-right:10px;">
									<span id="selectButtonIcon" class="fa fa-caret-down">高级查询</span>
								</button>
							</div>
						</div>
						<div class="panel-collapse collapse" id="selectDiv" style="margin-left:10px">
							<h:panelGrid columns="6" style="margin-top:8px;margin-bottom:10px" cellpadding="6">
								<p:outputLabel value="调管单位：" style="margin-right:5px;margin-bottom:5px;"/>
								<p:autoComplete dropdown="true" id="dispatchUnit_id"
									value="#{lineSegmentLedgerController.queryLedger.dispatchUnit}"
									style="margin-right:10px;margin-bottom:5px;" size="18"
									scrollHeight="200" placeholder="输入拼音首字母查询"
									completeMethod="#{ledgerQueryDataController.completeDispatchUnit}">
								</p:autoComplete>
								<p:outputLabel value="运维单位：" style="margin-right:5px;margin-bottom:5px;"/>
								<p:autoComplete dropdown="true" id="maintenanceUnit_id"
									value="#{lineSegmentLedgerController.queryLedger.maintenanceUnit}"
									style="margin-right:10px;margin-bottom:5px;" size="18"
									scrollHeight="200" placeholder="输入拼音首字母查询"
									completeMethod="#{ledgerQueryDataController.completeMaintenanceUnit}">
								</p:autoComplete>
								<p:outputLabel value="资产归属：" style="margin-right:5px;margin-bottom:5px;"/>
								<p:autoComplete dropdown="true" id="assetOwner_id"
									value="#{lineSegmentLedgerController.queryLedger.assetOwner}"
									style="margin-right:10px;margin-bottom:5px;" size="18"
									scrollHeight="200" placeholder="输入拼音首字母查询"
									completeMethod="#{ledgerQueryDataController.completeAssetOwner}">
								</p:autoComplete>
							</h:panelGrid>
							<h:panelGrid columns="4" style="margin-top:8px;margin-bottom:10px" cellpadding="6">
								<p:outputLabel value="一次设备检修范围：" style="margin-right:5px;margin-bottom:5px;"/>
								<p:autoComplete dropdown="true" id="primary_id"
									value="#{lineSegmentLedgerController.queryLedger.primaryEquipmentScope}"
									style="margin-right:15px;margin-bottom:5px;" size="18"
									scrollHeight="200" placeholder="输入拼音首字母查询"
									completeMethod="#{ledgerQueryDataController.completePrimaryAndSecondaryScope}">
								</p:autoComplete>
								<p:outputLabel value="二次设备检修范围：" style="margin-right:5px;margin-bottom:5px;"/>
								<p:autoComplete dropdown="true" id="secondary_id"
									value="#{lineSegmentLedgerController.queryLedger.secondaryEquipmentScope}"
									style="margin-right:15px;margin-bottom:5px;" size="18"
									scrollHeight="200" placeholder="输入拼音首字母查询"
									completeMethod="#{ledgerQueryDataController.completePrimaryAndSecondaryScope}">
								</p:autoComplete>
							</h:panelGrid>
						</div>
					</div>
					<p:toolbar id="toolbar">
						<f:facet name="left">
							<p:commandButton value="编辑" icon="ui-icon-pencil" id="editBtn" process="@all" actionListener="#{lineSegmentLedgerController.preEdit()}"
								rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgldwwh_bj')}"
								disabled="#{lineSegmentLedgerController.selectedLineledgerList.size() == 0}"
								oncomplete="PF('editDlg').show()" update=":editForm:editDlg"
								style="margin-right:5px" />
							<p:commandButton id="delBtn" icon="ui-icon-trash" value="清除单位设置"
								rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgldwwh_qcsz')}"
								disabled="#{lineSegmentLedgerController.selectedLineledgerList.size() == 0}"
								actionListener="#{lineSegmentLedgerController.cleanLedgers}"
								update="headForm:tabv headForm:msgs headForm:editBtn headForm:delBtn"
								style="margin-right:5px" >
								<p:confirm header="提示" message="确定清除所选记录的所有单位设置吗?" icon="ui-icon-alert" />
							</p:commandButton>
							<p:commandButton value="下载模板" ajax="false"
								rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgldwwh_xzmb')}"
								icon="ui-icon-arrowthick-1-s"
								actionListener="#{lineSegmentLedgerController.fileDownloadView()}"
								style="margin-right:5px" >
								<p:fileDownload value="#{lineSegmentLedgerController.templateFile}" />
							</p:commandButton>
							<p:commandButton id="newStatBtn" value="上传文件" icon="ui-icon-arrowthick-1-n"
								rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgldwwh_scwj')}"
								actionListener="#{lineSegmentLedgerController.openUploadDialog}"
								style="margin-right:5px" >
								<p:ajax event="dialogReturn" update="headForm:msgs headForm:tabv"
									listener="#{lineSegmentLedgerController.onSelectorChosen}" />
							</p:commandButton>
							<p:commandButton value="初始化数据" icon="ui-icon-refresh" id="initBtn" actionListener="#{lineSegmentLedgerController.initAllDate()}"
								rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgldwwh_cshsj')}"
								update=":headForm:tabv" />
						</f:facet>
					</p:toolbar>
					<p:tabView id="tabv" cache="false" dynamic="true" >
						<p:tab title="交流线路">
							<p:dataTable id="table1" var="item" rowKey="#{item.id}"
								emptyMessage="无记录" rowIndexVar="ite" 
								value="#{lineSegmentLedgerController.aclineModel}"
								selection="#{lineSegmentLedgerController.selectedLineledgerList}"
								lazy="true" rows="20" paginator="true" paginatorPosition="bottom"
								style="margin-bottom:0;text-align:center" 
								paginatorTemplate="{Customization} {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="20,50,100">
								<f:facet name="{Customization}">
									<p:outputLabel
										value="总计：#{lineSegmentLedgerController.rowCount} 条记录"
										style="margin-right:20px;" />
								</f:facet>
								<p:ajax event="rowSelectCheckbox" process="@all" update=":headForm:editBtn :headForm:delBtn" />
								<p:ajax event="rowUnselectCheckbox" process="@all" update=":headForm:editBtn :headForm:delBtn"/>
								<p:ajax event="rowSelect" process="@all" update=":headForm:editBtn :headForm:delBtn"/>
								<p:column selectionMode="multiple"
									style="text-align:center;width:50px" />
								<p:column headerText="序号" width="4%">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="线路名称" width="9%">
									<h:outputText value="#{item.name}" />
								</p:column>
								<p:column headerText="调管单位" width="9%">
									<h:outputText value="#{item.dispatchUnit}" />
								</p:column>
								<p:column headerText="运维单位" width="9%">
									<h:outputText value="#{item.maintenanceUnit}" />
								</p:column>
								<p:column headerText="单位类型" width="9%">
									<h:outputText value="#{item.unitType}" />
								</p:column>
								<p:column headerText="资产归属" width="9%">
									<h:outputText value="#{item.assetOwner}" />
								</p:column>
								<p:column headerText="一次设备检修范围" width="9%">
									<h:outputText value="#{item.primaryEquipmentScope}" />
								</p:column>
								<p:column headerText="一次设备检修范围备注" width="10%">
									<h:outputText value="#{item.primaryEquipmentScopeRemark}" />
								</p:column>
								<p:column headerText="二次设备检修范围" width="9%">
									<h:outputText value="#{item.secondaryEquipmentScope}" />
								</p:column>
								<p:column headerText="二次设备检修范围备注" width="10%">
									<h:outputText value="#{item.secondaryEquipmentScopeRemark}" />
								</p:column>
							</p:dataTable>
						</p:tab>
						<p:tab title="直流线路">
							<p:dataTable id="table" var="item" rowKey="#{item.id}"
								emptyMessage="无记录" rowIndexVar="ite" 
								value="#{lineSegmentLedgerController.dclineModel}"
								selection="#{lineSegmentLedgerController.selectedLineledgerList}"
								lazy="true" rows="20" paginator="true" paginatorPosition="bottom"
								style="margin-bottom:0;text-align:center" 
								paginatorTemplate="{Customization} {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="20,50,100">
								<f:facet name="{Customization}">
									<p:outputLabel
										value="总计：#{lineSegmentLedgerController.rowCount1} 条记录"
										style="margin-right:20px;" />
								</f:facet>
								<p:ajax event="rowSelectCheckbox" process="@all" update=":headForm:editBtn :headForm:delBtn" />
								<p:column selectionMode="multiple"
									style="text-align:center;width:50px" />
								<p:column headerText="序号" width="4%">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="线路名称" width="9%">
									<h:outputText value="#{item.name}" />
								</p:column>
								<p:column headerText="调管单位" width="9%">
									<h:outputText value="#{item.dispatchUnit}" />
								</p:column>
								<p:column headerText="运维单位" width="9%">
									<h:outputText value="#{item.maintenanceUnit}" />
								</p:column>
								<p:column headerText="单位类型" width="9%">
									<h:outputText value="#{item.unitType}" />
								</p:column>
								<p:column headerText="资产归属" width="9%">
									<h:outputText value="#{item.assetOwner}" />
								</p:column>
								<p:column headerText="一次设备检修范围" width="9%">
									<h:outputText value="#{item.primaryEquipmentScope}" />
								</p:column>
								<p:column headerText="一次设备检修范围备注" width="10%">
									<h:outputText value="#{item.primaryEquipmentScopeRemark}" />
								</p:column>
								<p:column headerText="二次设备检修范围" width="9%">
									<h:outputText value="#{item.secondaryEquipmentScope}" />
								</p:column>
								<p:column headerText="二次设备检修范围备注" width="10%">
									<h:outputText value="#{item.secondaryEquipmentScopeRemark}" />
								</p:column>
							</p:dataTable>
						</p:tab>
					</p:tabView>
				</h:form>
				<h:form id="editForm">
					<p:dialog widgetVar="editDlg" id="editDlg" width="500px" height="500px" header="编辑">
						<p:toolbar>
							<f:facet name="left">
								<p:commandButton value="保存" update=":headForm:tabv :headForm:msgs :headForm:lineSearch :headForm:vol :headForm:editBtn :headForm:delBtn"
									icon="ui-icon-disk" oncomplete="PF('editDlg').hide()" actionListener="#{lineSegmentLedgerController.save}" />
							</f:facet>
						</p:toolbar>
						<p:outputPanel style="width:100%;">
							<p:panelGrid style="width:100%;">
								<p:row>
									<p:column>
										<h:outputText value="线路名称" />
									</p:column>
									<p:column>
										<ui:repeat value="#{lineSegmentLedgerController.selectedLineledgerList}" var="ledger">
											<h:outputText value="#{ledger.name}" style="display:block"/>
										</ui:repeat>
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="调管单位" />
									</p:column>
									<p:column>
										<p:inputText id="orgDept" value="#{lineSegmentLedgerController.editLedger.dispatchUnit}" readonly="true"/>
										<p:commandButton value="选择" style="margin-left:5px"
											actionListener="#{ledgerQueryDataController.getDesorgDepartDialog()}" >
											<p:ajax event="dialogReturn" listener="#{lineSegmentLedgerController.onDesorgDepartChosen}"
												update="editForm:orgDept" />
										</p:commandButton>
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="资产归属" />
									</p:column>
									<p:column>
										<p:autoComplete scrollHeight="300" dropdown="true"
											value="#{lineSegmentLedgerController.editLedger.assetOwner}"
											completeMethod="#{ledgerQueryDataController.completeAssetOwnerWhenEdit}" />
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="运维单位" />
									</p:column>
									<p:column>
										<p:inputText id="opCompanyDept" value="#{lineSegmentLedgerController.editLedger.maintenanceUnit}" readonly="true"/>
										<p:commandButton value="选择" style="margin-left:5px"
											actionListener="#{ledgerQueryDataController.getOpDepartDialog()}" >
											<p:ajax event="dialogReturn" listener="#{lineSegmentLedgerController.onOpDepartChosen}"
												update="opCompanyDept unitType" />
										</p:commandButton>
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="单位类型" />
									</p:column>
									<p:column>
										<p:autoComplete scrollHeight="300" dropdown="true" style="width:75%"
											value="#{lineSegmentLedgerController.editLedger.unitType}" id="unitType"
											completeMethod="#{ledgerQueryDataController.completeUnitType}">
										</p:autoComplete>
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="一次设备检修范围" />
									</p:column>
									<p:column>
										<p:inputText id="primary" value="#{lineSegmentLedgerController.editLedger.primaryEquipmentScope}" readonly="true"/>
										<p:commandButton value="选择" style="margin-left:5px"
											actionListener="#{ledgerQueryDataController.getPrimaryAndSecondaryScopeSelectDialog()}" >
											<p:ajax event="dialogReturn" listener="#{lineSegmentLedgerController.onPrimaryScopeChosen}"
												update="primary" />
										</p:commandButton>
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="一次设备检修范围备注" />
									</p:column>
									<p:column>
										<p:inputText style="width:78%"
											value="#{lineSegmentLedgerController.editLedger.primaryEquipmentScopeRemark}" />
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="二次设备检修范围" />
									</p:column>
									<p:column>
										<p:inputText id="secondary" value="#{lineSegmentLedgerController.editLedger.secondaryEquipmentScope}" readonly="true"/>
										<p:commandButton value="选择" style="margin-left:5px"
											actionListener="#{ledgerQueryDataController.getPrimaryAndSecondaryScopeSelectDialog()}" >
											<p:ajax event="dialogReturn" listener="#{lineSegmentLedgerController.onSecondryScopeChosen}"
												update="secondary" />
										</p:commandButton>
									</p:column>
								</p:row>
								<p:row>
									<p:column>
										<h:outputText value="二次设备检修范围备注" />
									</p:column>
									<p:column>
										<p:inputText style="width:78%"
											value="#{lineSegmentLedgerController.editLedger.secondaryEquipmentScopeRemark}" />
									</p:column>
								</p:row>
							</p:panelGrid>
						</p:outputPanel>
					</p:dialog>
				</h:form>
			</div>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script>
			function onSelectDivClick() {
				var div = $('#selectDiv');
				if (div.hasClass('in')) {
					div.collapse('hide');
					$('#selectButtonIcon').removeClass("fa fa-caret-up");
					$('#selectButtonIcon').addClass("fa fa-caret-down");
				} else {
					div.collapse('show');
					$('#selectButtonIcon').removeClass("fa fa-caret-down");
					$('#selectButtonIcon').addClass("fa fa-caret-up");
				}
			}
			function closeDivClick() {
				var div = $('#selectDiv');
				div.collapse('hide');
				$('#selectButtonIcon').removeClass("fa fa-caret-up");
				$('#selectButtonIcon').addClass("fa fa-caret-down");
			}
		</script>
	</ui:define>
</ui:composition>
